import { useEffect, useState } from "react";
export const useScrollBottom = () => {
    const [isBottom, setIsBottom] = useState(false);
    const handleScroll = () => {
        const clientHeight = document.documentElement.clientHeight;
        const scrollTop = document.documentElement.scrollTop; //滚动条滚动高度
        const scrollHeight = document.documentElement.scrollHeight; //滚动内容高度
        if (Math.floor(clientHeight + scrollTop) >= scrollHeight - 10) {
            setIsBottom(true);
        } else {
            setIsBottom(false);
        }
    };
    useEffect(() => {
        window.addEventListener("scroll", handleScroll);
        return () => {
            window.removeEventListener("scroll", handleScroll);
        };
    });
    return [isBottom];
};